@extends(all)
@args User user
<form class="layui-form" style="width:70%;margin-left: 10%;margin-top: 10%" action="/user/edit" method="post">
    <input type="hidden" name="id" class="layui-input id" value="@user.id@">
    <div class="layui-form-item">
        <label class="layui-form-label">登录名</label>
        <div class="layui-input-block">
            <input type="text" name="username" value="@user.username@" class="layui-input userName" lay-verify="required" placeholder="请输入登录名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-block">
            <input id="password" type="password" name="passhash" lay-verify="false" placeholder="更新密码，如果不填则不修改。。。"
                   autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="editUser">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form'], function () {
        var form = layui.form();
        //监听提交
        form.on('submit(editUser)', function(data) {
                $.post({
                    url: data.form.action,
                    data:{
                        json:JSON.stringify(data.field)
                    },
                    success: function (obj) {
                        if(obj.status == 200){
                            layer.msg(obj.msg, {time:1000});
                            setTimeout("parent.layer.closeAll();parent.App.loadUsers();",1000);
                        }
                        else{
                            layer.msg(obj.msg);
                        }
                    },
                    error: function(data) {
                        layer.msg("网络错误");
                    }
                });
            return false;
        });
    });
</script>
